﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Cfg;
using System.Reflection;

namespace Caduceu.Estudos.DAL
{
    public class NHibernateHelper
    {
        protected static readonly ISessionFactory sessionFactory = null;
        
        static NHibernateHelper()
        {
            sessionFactory = new Configuration().Configure(Assembly.GetExecutingAssembly(), "Caduceu.Estudos.DAL.MySql.cfg.xml")
                .BuildSessionFactory();            
        }

        public static ISession GetSession()
        {
            return sessionFactory.OpenSession();
        }

        public static void CloseSessionFactory()
        {
            sessionFactory.Close();
        }
    }
}
